package com.shenma2009.controller;

import com.shenma2009.domain.ResultResponse;
import com.shenma2009.service.TbOrderService;
import com.shenma2009.vo.IdVo;
import com.shenma2009.vo.PageVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 军哥
 * @version 1.0
 * @description: TbOrderController
 * @date 2023/4/25 16:29
 */

@RestController
@Slf4j
@RequestMapping(value = "/order")
public class TbOrderController {

    @Autowired
    TbOrderService tbOrderService;

    @PostMapping(value = "/add")
    public ResultResponse add(HttpServletRequest request, @RequestBody IdVo idVo) {

        String token = request.getHeader("token");

        return tbOrderService.add(idVo, token);
    }

    @PostMapping(value = "/list")
    public ResultResponse list(@RequestBody PageVo pageVo) {
        return tbOrderService.listByPage(pageVo);
    }

}
